﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

using ImageRecognition2.Forms;

using LowLevelGraphics.CustomControls;

using LowLevelGraphics.VideoFormats;
using LowLevelGraphics;
using LowLevelGraphics.Filter;

namespace ImageRecognition2
{
    /// <summary>
    /// MainFormSingleton
    /// </summary>
    public sealed class MainFormSingleton
    {
        private static IFilter lastExecutedFilter = new MacroFilter();

        private static Form1 form = null;

        private static UnsafeBitmap m_OriginalBitmap = null;

        /// <summary>
        /// private constructor
        /// </summary>
        private MainFormSingleton()
        {
        }

        /// <summary>
        /// Create this singleton
        /// </summary>
        /// <param name="_form"></param>
        public static void Create(Form1 _form)
        {
            form = _form;
        }

        public static UnsafeBitmap OriginalBitmap
        {
            get
            {
                return m_OriginalBitmap;
            }
            internal set { m_OriginalBitmap = value; }
        }

        /// <summary>
        /// returns form1 inst6ance
        /// </summary>
        public static Form1 Instance
        {
            get { return form; }
        }

        public static IFilter LastExecutedFilter
        {
            get { return lastExecutedFilter; }
            internal set { lastExecutedFilter = value; }
        }

        public static AVI AVI
        {
            get { return form.m_AVI; }
        }

        /// <summary>
        /// Gets the active form child.
        /// </summary>
        /// <value>The active form child.</value>
        public static FormChild ActiveFormChild
        {
            get
            {
                FormChild formChild = form.ActiveMdiChild as FormChild;
                if (formChild != null)
                {
                    return formChild;
                }
                return null;
            }
        }

        /// <summary>
        /// returns the active picturebox
        /// </summary>
        public static SelectablePictureBox ActivePictureBox
        {
            get
            {
                FormChild formChild = form.ActiveMdiChild as FormChild;
                if (formChild != null)
                {
                    return formChild.pictureBox1;
                }
                return null;
            }
        }
    }
}
